<?php
/*
  Copyright 2010 Mark Watkinson

  This file is part of Luminous.

  Luminous is free software: you can redistribute it and/or
  modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  Luminous is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with Luminous.  If not, see <http://www.gnu.org/licenses/>.

*/
/**
 * \file luminous_example.php
 * \brief A short example for calling Luminous
 */ 

  require_once('luminous.php'); 
  
  // Luminous shouldn't ever get caught in an infinite loop even on the most
  // terrible and malformed input, but I think you'd be daft to run it with no
  // safeguard.
  set_time_limit(3);

?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title> Example </title>
  <!-- if you forget this it won't look so good //-->
  <link rel="stylesheet" type="text/css" href="../style/luminous.css">
</head>

<body>

<h1> A simple example usage for Luminous</h1>
<p> Inspect the source code to see what's going on. </p>
<p> 
An unconstrained, uncontained code display. If you want to use it like this, 
set style='padding:0px; margin:0px;' on the body element to remove the white 
border to the left.
</p>
<? echo luminous('cpp', '#include <stdio.h>
int main()
{
  printf("hello, world");
  return 0;
}
'); ?>
  
  
<p>

But you'll find if you only want to display a short code exerpt, it looks a lot better like this, wrapped in a div with 
style= 'margin-left:auto; margin-right:auto; border:1px solid black;'. The margins make it centred. 

</p>

<div style='width:50%; margin-left:auto;margin-right:auto; border:1px solid black;'>
<?
echo luminous('cpp', '#include <stdio.h>
int main()
{
  printf("hello, world");
  return 0;
}
');
  ?>
</div>


<p>
This is from jQuery,  Copyright 2010, John Resig, which I use to show a dimension constrained container with scrollbars.
The style for the container div is: style='width:50%; height:250px; margin-left:auto;margin-right:auto; border:1px solid black; overflow:auto'
</p>
<div style='width:50%; height:250px; margin-left:auto;margin-right:auto; border:1px solid black; overflow:auto'>

<?

echo "";

echo luminous('js', 'function cloneCopyEvent(orig, ret) {
  var i = 0;
  
  ret.each(function() {
    if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
      return;
    }
      
    var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData), events = oldData && oldData.events;
      
    if ( events ) {
      delete curData.handle;
      curData.events = {};
        
      for ( var type in events ) {
        for ( var handler in events[ type ] ) {
          jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][
          handler ].data );
        }
      }
    }
  });
}');
  ?>
  </div>
</body>
</html>
